/*
 * @Descripttion: 
 * @Author: junhuafly
 * @Date: 2020-04-15 13:48:03
 * @LastEditors: junhuafly
 * @Email: junhuafly@163.com
 * @LastEditTime: 2020-04-20 13:50:35
 */
// components/navbar/index.js
const app = getApp()
Component({
  externalClasses: ['custom-class','title-class'],
  properties: {
    navbarData: {   //navbarData   由父页面传递的数据，变量名字自命名
      type: Object,
      value: {
        showCapsule: 1
      },
      observer: function (newVal, oldVal) {}
    },
    title:{
      type:String,
      value:''
    },
    useSlot:Boolean
  },
  ready(){
    this.setData({
      'navbarData.title':app.globalData.title
    })
  },
  data: {
    height: '',
    //默认值  默认显示左上角
    navbarData: {
      showCapsule: 1
    }
  },
  attached: function () {
    let modellers = wx.getStorageSync('modellers');
    var appInst =  getApp();
    let isIphoneX = appInst.globalData.isIphoneX;
    this.setData({
      isIphoneX,
    })
    // 获取是否是通过分享进入的小程序
    this.setData({
      share: app.globalData.share
    })
    // 定义导航栏的高度   方便对齐
    this.setData({
      height: app.globalData.height
    })
  },
  methods: {
  // 返回上一页面
    _navback() {
      if(this.data.navbarData.back){
        this.triggerEvent('back')
        return
      }
      wx.navigateBack()
    },
  //返回到首页
    _backhome() {
      wx.switchTab({
        url: '/pages/note/index',
      })
    }
  }

}) 